/*
 * Copyright 2012 Benoît Combe <benoit.combe@gmail.com>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package fr.ipst.spot.entites;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Benoît Combe <benoit.combe@gmail.com>
 */
@Entity
@Table(name = "AgentExterieur", catalog = "SPOT", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AgentExterieur.findAll", query = "SELECT a FROM AgentExterieur a"),
    @NamedQuery(name = "AgentExterieur.findByIdAgentExterieur", query = "SELECT a FROM AgentExterieur a WHERE a.idAgentExterieur = :idAgentExterieur"),
    @NamedQuery(name = "AgentExterieur.findByNom", query = "SELECT a FROM AgentExterieur a WHERE a.nom = :nom"),
    @NamedQuery(name = "AgentExterieur.findByPrenom", query = "SELECT a FROM AgentExterieur a WHERE a.prenom = :prenom"),
    @NamedQuery(name = "AgentExterieur.findByTelephone", query = "SELECT a FROM AgentExterieur a WHERE a.telephone = :telephone"),
    @NamedQuery(name = "AgentExterieur.findByMail", query = "SELECT a FROM AgentExterieur a WHERE a.mail = :mail"),
    @NamedQuery(name = "AgentExterieur.findByFonction", query = "SELECT a FROM AgentExterieur a WHERE a.fonction = :fonction")})
public class AgentExterieur extends AbstractSpotEntite implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idAgentExterieur", nullable = false)
    private Integer idAgentExterieur;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "nom", nullable = false, length = 45)
    private String nom;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "prenom", nullable = false, length = 45)
    private String prenom;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 13)
    @Column(name = "telephone", nullable = false, length = 13)
    private String telephone;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "mail", nullable = false, length = 255)
    private String mail;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "fonction", nullable = false, length = 255)
    private String fonction;
    @JoinColumn(name = "idOrganisme", referencedColumnName = "idOrganisme", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Organisme organisme;
    @OneToMany(mappedBy = "agentExterieur", fetch = FetchType.LAZY)
    private List<Evenement> evenementList;

    /**
     *
     */
    public AgentExterieur() {
    }

    /**
     *
     * @param idAgentExterieur
     */
    public AgentExterieur(Integer idAgentExterieur) {
        this.idAgentExterieur = idAgentExterieur;
    }

    /**
     *
     * @param idAgentExterieur
     * @param nom
     * @param prenom
     * @param telephone
     * @param mail
     * @param fonction
     */
    public AgentExterieur(Integer idAgentExterieur, String nom, String prenom, String telephone, String mail, String fonction) {
        this.idAgentExterieur = idAgentExterieur;
        this.nom = nom;
        this.prenom = prenom;
        this.telephone = telephone;
        this.mail = mail;
        this.fonction = fonction;
    }

    /**
     *
     * @return
     */
    public Integer getIdAgentExterieur() {
        return idAgentExterieur;
    }

    /**
     *
     * @param idAgentExterieur
     */
    public void setIdAgentExterieur(Integer idAgentExterieur) {
        this.idAgentExterieur = idAgentExterieur;
    }

    /**
     *
     * @return
     */
    public String getNom() {
        return nom;
    }

    /**
     *
     * @param nom
     */
    public void setNom(String nom) {
        this.nom = nom;
    }

    /**
     *
     * @return
     */
    public String getPrenom() {
        return prenom;
    }

    /**
     *
     * @param prenom
     */
    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    /**
     *
     * @return
     */
    public String getTelephone() {
        return telephone;
    }

    /**
     *
     * @param telephone
     */
    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    /**
     *
     * @return
     */
    public String getMail() {
        return mail;
    }

    /**
     *
     * @param mail
     */
    public void setMail(String mail) {
        this.mail = mail;
    }

    /**
     *
     * @return
     */
    public String getFonction() {
        return fonction;
    }

    /**
     *
     * @param fonction
     */
    public void setFonction(String fonction) {
        this.fonction = fonction;
    }

    /**
     *
     * @return
     */
    public Organisme getOrganisme() {
        return organisme;
    }

    /**
     *
     * @param organisme
     */
    public void setOrganisme(Organisme organisme) {
        this.organisme = organisme;
    }

    /**
     *
     * @return
     */
    @XmlTransient
    public List<Evenement> getEvenementList() {
        return evenementList;
    }

    /**
     *
     * @param evenementList
     */
    public void setEvenementList(List<Evenement> evenementList) {
        this.evenementList = evenementList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAgentExterieur != null ? idAgentExterieur.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AgentExterieur)) {
            return false;
        }
        AgentExterieur other = (AgentExterieur) object;
        if ((this.idAgentExterieur == null && other.idAgentExterieur != null) || (this.idAgentExterieur != null && !this.idAgentExterieur.equals(other.idAgentExterieur))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.ipst.spot.entites.AgentExterieur[ idAgentExterieur=" + idAgentExterieur + " ]";
    }

    /**
     *
     * @return
     */
    @Override
    public Integer getId() {
        return this.idAgentExterieur;
    }
}
